package com.htfyun.roobofactory.rooboUtils;

import android.media.AudioFormat;
import android.media.MediaRecorder;
import android.os.Environment;

import java.io.File;

public class AudioFileAttribute {
    public final static int AUDIO_INPUT = MediaRecorder.AudioSource.MIC;

    // **NOTE** 修改时需要同时修改CONFIGURATION and MAC_NUM
    public final static int CHANNEL_CONFIGURATION = AudioFormat.CHANNEL_CONFIGURATION_MONO;
    public final static int CHANNEL_MAC_NUM = 1;

    // **NOTE** 修改时需要同时修改ENCODING_BIT_RATE and ENCODING_BITWIDTH
    public final static int ENCODING_BIT_RATE = AudioFormat.ENCODING_PCM_16BIT;
    public static final int ENCODING_BITWIDTH = 16;

    public final static int AUDIO_SAMPLE_RATE = 16000;

    // 录音输出文件
    private final static String AUDIO_RAW_FILENAME = "juan.pcm";
    private final static String AUDIO_RAW_FILENAME_WAV = "juan.wav";

    /**
     * 判断是否有外部存储设备sdcard
     *
     * @return true | false
     */
    public static boolean isSdcardExit() {
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
            return true;
        else
            return false;
    }

    /**
     * 获取文件大小
     *
     * @param path 文件的绝对路径
     * @return
     */
    public static long getFileSize(String path) {
        File mFile = new File(path);
        if (!mFile.exists())
            return -1;
        return mFile.length();
    }

}
